<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates an empty DOMDocumentType object</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="domimplementation.createdocument.html">« DOMImplementation::createDocument</a></li>
      <li style="float: right;"><a href="domimplementation.hasfeature.html">DOMImplementation::hasFeature »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.domimplementation.html">DOMImplementation</a></li>
    <li>Creates an empty DOMDocumentType object</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="domimplementation.createdocumenttype" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMImplementation::createDocumentType</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DOMImplementation::createDocumentType</span> &mdash; <span class="dc-title">
   Creates an empty DOMDocumentType object
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-domimplementation.createdocumenttype-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>DOMImplementation::createDocumentType</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$qualifiedName</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$publicId</code><span class="initializer"> = &quot;&quot;</span></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$systemId</code><span class="initializer"> = &quot;&quot;</span></span>): <span class="type"><span class="type"><a href="class.domdocumenttype.html" class="type DOMDocumentType">DOMDocumentType</a></span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Creates an empty <span class="classname"><a href="class.domdocumenttype.html" class="classname">DOMDocumentType</a></span> object. Entity 
   declarations and notations are not made available. Entity reference 
   expansions and default attribute additions do not occur.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-domimplementation.createdocumenttype-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">qualifiedName</code></dt>

     <dd>

      <p class="para">
       The qualified name of the document type to create.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">publicId</code></dt>

     <dd>

      <p class="para">
       The external subset public identifier.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">systemId</code></dt>

     <dd>

      <p class="para">
       The external subset system identifier.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domimplementation.createdocumenttype-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   A new <span class="classname"><a href="class.domdocumenttype.html" class="classname">DOMDocumentType</a></span> node with its 
   <code class="literal">ownerDocument</code> set to <strong><code>null</code></strong>.
  </p>
 </div>

 <div class="refsect1 errors" id="refsect1-domimplementation.createdocumenttype-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   <dl>
    
     <dt>
<strong><code>DOM_NAMESPACE_ERR</code></strong></dt>

     <dd>

      <p class="para">
       Raised if there is an error with the namespace, as determined by 
       <code class="parameter">qualifiedName</code>.
      </p>
     </dd>

    
   </dl>

  </p>
  <p class="para">在 PHP 8.0.0 之前<em class="emphasis">可以</em>静态调用此方法，但会发出
<strong><code>E_DEPRECATED</code></strong> 错误。自 PHP 8.0.0 起，静态调用此方法会抛出 <span class="classname"><a href="class.error.html" class="classname">Error</a></span> 异常</p>
 </div>

 <div class="refsect1 examples" id="refsect1-domimplementation.createdocumenttype-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5417">
    <p><strong>示例 #1 Creating a document with an attached DTD</strong></p>
    <div class="example-contents">
 <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Creates&nbsp;an&nbsp;instance&nbsp;of&nbsp;the&nbsp;DOMImplementation&nbsp;class<br /></span><span style="color: #0000BB">$imp&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMImplementation</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Creates&nbsp;a&nbsp;DOMDocumentType&nbsp;instance<br /></span><span style="color: #0000BB">$dtd&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$imp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDocumentType</span><span style="color: #007700">(</span><span style="color: #DD0000">'graph'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'graph.dtd'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Creates&nbsp;a&nbsp;DOMDocument&nbsp;instance<br /></span><span style="color: #0000BB">$dom&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$imp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDocument</span><span style="color: #007700">(</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$dtd</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Set&nbsp;other&nbsp;properties<br /></span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">encoding&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'UTF-8'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">standalone&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;an&nbsp;empty&nbsp;element<br /></span><span style="color: #0000BB">$element&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'graph'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Append&nbsp;the&nbsp;element<br /></span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">appendChild</span><span style="color: #007700">(</span><span style="color: #0000BB">$element</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Retrieve&nbsp;and&nbsp;print&nbsp;the&nbsp;document<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">saveXML</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
&lt;!DOCTYPE graph SYSTEM &quot;graph.dtd&quot;&gt;
&lt;graph/&gt;
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-domimplementation.createdocumenttype-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="domimplementation.createdocument.html" class="methodname" rel="rdfs-seeAlso">DOMImplementation::createDocument()</a> - Creates a DOMDocument object of the specified type with its document element</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>